<!DOCTYPE html>
<html>
    
    <head>
        <meta charset="utf-8">
        <title>
            X-admin v1.0
        </title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="__PUBLIC__/admin/css/x-admin.css" media="all">
    </head>
    
    <body>
        <div class="x-body">
            <form action="" method="post" class="layui-form layui-form-pane">
                <div class="layui-form-item">
                    <label for="name" class="layui-form-label">
                        <span class="x-red">*</span>ID
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" name="id" autocomplete="off" class="layui-input" value="{$stutags_one.id}" disabled>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="name" class="layui-form-label">
                        <span class="x-red">*</span>标题
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" name="name" required="" lay-verify="required" autocomplete="off" class="layui-input" value="{$stutags_one.name}">
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label for="desc" class="layui-form-label">
                        <span class="x-red">*</span>内容
                    </label>
                    <div class="layui-input-block">
                        <textarea id="L_content" name="content" class="layui-textarea fly-editor" style="height: 160px;">{$stutags_one['content']}</textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                <button class="layui-btn" lay-submit="" lay-filter="add">修改</button>
              </div>
            </form>
        </div>
        <script src="__PUBLIC__/admin/lib/layui/layui.js" charset="utf-8">
        </script>
        <script src="__PUBLIC__/admin/js/x-layui.js" charset="utf-8">
        </script>
        <script>
            layui.use(['form','layer','layedit' ,'laypage', 'element','upload'], function(){
                $ = layui.jquery;
              var form = layui.form()
              ,laypage = layui.laypage
              ,layedit = layui.layedit
              ,element = layui.element()
              ,upload = layui.upload
              ,layer = layui.layer;

              //创建一个编辑器
              var editIndex = layedit.build('L_content', {height: 200,
                            tool: ['strong','italic','underline','del','left', 'center', 'right', '|', 'face','link']
                            });
              //监听提交
              form.on('submit(add)', function(data){
                data.field.content = layedit.getContent(editIndex);
                //发异步，把数据提交给php
                $.ajax({
                    url: "{:U('admin/log/dibu_index_edit_add')}",//请求地址
                    type: "post",//请求方式
                    dataType: "json",//返回数据类型
                    data: data.field,//发送的参数
                    })
                    .done(function(response) {
                          if(response.error==0){
                             layer.msg(response.info ,{icon:5});
                          }else{
                            layer.alert(response.info, {icon: 6},function () {
                                // 获得frame索引
                                var index = parent.layer.getFrameIndex(window.name);
                                //关闭当前frame
                                parent.layer.close(index);
                                parent.location.reload();

                            });
                          }
                      })
                    .fail(function() {
                        alert("ajxs交互失败");
                    })  
                return false;
              });
              
              
            });
        </script>
    </body>

</html>